<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 梁家源
  Date: 2021/4/1
  Time: 20:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/css/layui.css"/>
    <script src="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/layui.js" type="text/javascript"
            charset="UTF-8"></script>
    <script src="${pageContext.request.contextPath}/static/script/jquery-1.7.2.js" type="text/javascript"
            charset="UTF-8"></script>
</head>
<body>
<script>
    layui.use('form', function () {
        var form = layui.form;
    });


</script>
<fieldset class="layui-elem-field layui-field-title" style="margin: 20px" >
    <legend style="margin-left: 50px;">类别管理</legend>
</fieldset>
<div class="layui-container">
<%--    搜索区域--%>
    <div class="layui-row">
        <div class="layui-col-md4">
            <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/queryCategory" method="post">
                <div class="layui-form-item">
                    <div class="layui-input-inline" style="width: 172px">
                        <input type="text" class="layui-input" name="cname" placeholder="请输入要查寻的类别名称" autocomplete="off" lay-verify="required">
                    </div>
                    <div class="layui-input-inline">
                        <button class="layui-btn layui-btn-radius" title="搜索" lay-submit lay-filter="formDemo">
                            <i class="layui-icon">&#xe615;</i>
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-col-md7">
            <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/addCategory" method="post">
                <div class="layui-form-item">
                    <div class="layui-input-inline" style="width: 200px">
                        <input type="text" class="layui-input" name="cname" lay-verify="required" placeholder="新增的类别名称" autocomplete="off">
                    </div>
                    <div class="layui-input-inline">
                        <button class="layui-btn layui-btn-radius" title="增加" lay-submit lay-filter="formDemo">
                            <i class="layui-icon">&#xe624;</i>
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="layui-row" style="margin: 10px">
        <%--展示表格区域--%>
        <div class="layui-col-md8">
            <table class="layui-table" lay-skin="nob">
                <colgroup>
                    <col width="100px">
                    <col width="180px">
                    <col width="330px">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>序号</th>
                    <th>类别编号</th>
                    <th>类别名称</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="cate" varStatus="status" items="${categories}">
                    <tr>
                        <th>${status.count}</th>
                        <th>${cate.cid}</th>
                        <th>${cate.cname}</th>
                        <td>
                            <a href="${pageContext.request.contextPath}/gotoUpdCatePage?cid=${cate.cid}">
                                <button type="button" class="layui-btn-sm layui-btn-primary" title="修改类别">
                                    <i class="layui-icon">&#xe642;</i>
                                </button>
                            </a>&nbsp;&nbsp;&nbsp;&nbsp;
                            <a href="${pageContext.request.contextPath}/deleteCategory?cid=${cate.cid}">
                                <button type="button" class="layui-btn-sm layui-btn-primary" title="删除类别">
                                    <i class="layui-icon">&#xe640;</i>
                                </button>
                            </a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>

            </table>
        </div>
        <%--修改框区域--%>
        <div class="layui-col-md4">
            <div style="padding-left: 30px;padding-top: 10px">
                <div style="padding: 17px;border: 1px solid ; border-color: #e4dde4">
                    <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/updateCategory" method="post">
                        <div class="layui-form-item">
                            <label class="layui-form-label">旧类别名</label>
                            <div class="layui-input-block">
                                <input type="text" name="" value="${category.cname}" class="layui-input" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新类别名</label>
                            <div class="layui-input-block">
                                <input type="text" name="cname" value="${category.cname}" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <input type="hidden" name="cid" class="form-control" value="${category.cid}" />
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formDemo" title="修改">
                                    <i class="layui-icon">&#xe605;</i>
                                </button>
                                <button type="reset" class="layui-btn layui-btn-primary" title="重置">
                                    <i class="layui-icon">&#x1006;</i>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>




</div>
</body>


